cmake_minimum_required (VERSION 2.6 FATAL_ERROR)
SET(CMAKE_BUILD_TYPE Release)
project      (pcl-visualizer)
find_package (Qt5 COMPONENTS Widgets)
find_package (VTK 7.0.0 REQUIRED)
find_package (PCL 1.8.0 REQUIRED)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wno-unused-local-typedefs " ) #-Wreturn-type
SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O2" )
ADD_DEFINITIONS(-DRAPTER_WITH_BONMIN)

SET( dir ${CMAKE_CURRENT_SOURCE_DIR}/build/ )

include_directories (${PCL_INCLUDE_DIRS} include)
link_directories    (${PCL_LIBRARY_DIRS})
add_definitions     (${PCL_DEFINITIONS})

# OpenMP
FIND_PACKAGE(OpenMP)
IF(OPENMP_FOUND)
    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
ENDIF(OPENMP_FOUND)

#BONMIN
SET( PATH_BONMIN_DIR /home/alexaway/Mine/Bonmin-1.7.5/build/)
# Bonmin
IF(EXISTS ${PATH_BONMIN_DIR}lib/libcoinhsl.so)
  SET (BONMIN_SOLVER_LIB ${PATH_BONMIN_DIR}lib/libcoinhsl.so)
  MESSAGE(STATUS "HSL Solver available, using HSL instead of MUMPS")
ELSE()
    SET (BONMIN_SOLVER_LIB ${PATH_BONMIN_DIR}lib/libcoinmumps.so)
ENDIF(EXISTS ${PATH_BONMIN_DIR}lib/libcoinhsl.so)

SET(BONMIN_LIBRARIES
    ${PATH_BONMIN_DIR}/lib/libipopt.so
    ${PATH_BONMIN_DIR}/lib/libbonmin.so
    ${PATH_BONMIN_DIR}/lib/libCbc.so
    ${PATH_BONMIN_DIR}/lib/libCgl.so
    ${PATH_BONMIN_DIR}/lib/libClp.so
    ${BONMIN_SOLVER_LIB}
    ${PATH_BONMIN_DIR}/lib/libCoinUtils.so
    ${PATH_BONMIN_DIR}/lib/libOsi.so
    ${PATH_BONMIN_DIR}/lib/libOsiClp.so
    lapack
    dl
)
INCLUDE_DIRECTORIES( ${PATH_BONMIN_DIR}/include )

SET( RAPTER_HPP_LIST
    include/rapter/io/impl/io.hpp 
    include/rapter/io/inputParser.hpp
    include/rapter/optimization/impl/merging.hpp
    include/rapter/optimization/impl/segmentation.hpp
    include/rapter/optimization/impl/problemSetup.hpp
    include/rapter/optimization/impl/candidateGenerator.hpp
    include/rapter/optimization/impl/solver.hpp
    include/rapter/optimization/represent.hpp
    include/rapter/primitives/impl/taggable.hpp
    include/rapter/primitives/impl/planePrimitive.hpp
    include/rapter/primitives/impl/linePrimitive.hpp
    include/rapter/processing/util.hpp
    include/rapter/util/util.hpp
    include/rapter/util/containers.hpp
    include/rapter/visualization/impl/visualization.hpp
    include/rapter/visualization/visualizer.hpp
    include/rapter/processing/impl/angleUtil.hpp
    include/rapter/util/diskUtil.hpp
    include/qcqpcpp/impl/optProblem.hpp
)

SET( RAPTER_H_LIST  
    include/workthread/workthread.h
    include/rapter/simpleTypes.h
    include/rapter/typedefs.h
    include/rapter/parameters.h  
    include/rapter/io/io.h
    include/rapter/optimization/mergingFunctors.h
    include/rapter/optimization/merging.h
    include/rapter/optimization/energyFunctors.h
    include/rapter/optimization/problemSetup.h
    include/rapter/optimization/segmentation.h
    include/rapter/optimization/candidateGenerator.h
    include/rapter/optimization/solver.h
    include/rapter/primitives/angles.h
    include/rapter/primitives/linePrimitive.h
    include/rapter/primitives/taggable.h
    include/rapter/primitives/primitive.h
    include/rapter/primitives/pointPrimitive.h
    include/rapter/primitives/planePrimitive.h
    include/rapter/util/parse.h
    include/rapter/util/pclUtil.h
    include/rapter/visualization/visualization.h
    include/qcqpcpp/optProblem.h
    include/qcqpcpp/bonminOptProblem.h
    include/qcqpcpp/io/io.h
)

# Common template instantiations for all projects 
SET( TEMPLATE_INST_SRC_LIST
    include/workthread/workthread.cpp
    include/templateInstantiation/taggable.cpp
    include/templateInstantiation/primitive.cpp
    include/templateInstantiation/linePrimitive.cpp
    include/templateInstantiation/planePrimitive.cpp
    include/templateInstantiation/segmentation.cpp   
    include/templateInstantiation/problemSetup3D.cpp
    include/templateInstantiation/solve3D.cpp
    include/templateInstantiation/represent.cpp
    include/templateInstantiation/merge.cpp
)
set  (project_SOURCES main.cpp pclviewer.cpp ${TEMPLATE_INST_SRC_LIST})
set  (project_HEADERS pclviewer.h)
set  (project_FORMS   pclviewer.ui)
#set  (VTK_LIBRARIES   vtkRendering vtkGraphics vtkHybrid QVTK)


#INCLUDE         (${QT_USE_FILE})
#ADD_DEFINITIONS (${QT_DEFINITIONS})

ADD_EXECUTABLE  (pcl_visualizer ${project_SOURCES}
				${RAPTER_HPP_LIST} ${RAPTER_H_LIST})

TARGET_LINK_LIBRARIES (pcl_visualizer ${PCL_LIBRARIES} ${VTK_LIBRARIES} ${BONMIN_LIBRARIES})
qt5_use_modules(pcl_visualizer Widgets)
